package com.niit.session14.inner;
//方法内部类（局部内部类），不常用
//银行类
public class Bank {
	
//	开户方法
	public void openAccount(String name, int balance) {
//		把类定义在方法内部，这个类会在这个方法内生效
		class Customer {
			private String name;
			private int balance;

			public Customer(String name, int balance) {
				this.name = name;
				this.balance = balance;
			}
//			存钱
			public void deposit(int amount) {
				balance += amount;
			}
//			取钱
			public void withdraw(int amount) {
				balance -= amount;
			}
//			查询余额
			public int getBalance() {
				return balance;
			}
		}
//		实例化一个用户类
		Customer customer = new Customer(name, balance);
//		存钱
		customer.deposit(1000);
//		取钱
		customer.withdraw(100);
//		取钱
		System.out.println("账户余额"+customer.getBalance());
	}
	public static void main(String[] args) {
		Bank bank = new Bank();
		bank.openAccount("Trout", 10);
	}
	
	
}
